/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.upc.dew.serviciosmultiples.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import pe.edu.upc.dew.serviciosmultiples.model.Usuario;

/**
 *
 * @author bcano
 */
public class LoginValidator implements Validator {

    @Override
    public boolean supports(Class aClass) {
        return Usuario.class.equals(aClass);
    }

    @Override
    public void validate(Object obj, Errors errors) {
        Usuario usuario = (Usuario) obj;

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName", "field.required", "valor requerido");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "usuPassword", "field.required", "valor requerido");
    }

}
